﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Insteon.Messages.Insteon
{

    internal class AllLinkCleanupMessage : Message
    {
        internal const int MessCommand = 0x58;
        internal const int MessLength = 3;

        internal readonly byte Group;
        internal readonly byte Command;
        internal readonly ResponseStatus Status;

        public AllLinkCleanupMessage(byte[] buffer, UInt16 Length, UInt64 Number, out UInt16 Size)
            : base(buffer, Length, Number)
        {
            if (!Check(buffer, Length))
            {
                throw new Exception("Invalid message format");
            }

            Command = buffer[3];
            Group = buffer[2];
            Status = new ResponseStatus(buffer[5]);
            Size = MessLength;
        }

        internal static bool Check(byte[] buffer, UInt16 length)
        {
            if ((length >= MessLength) && (buffer[1] == MessCommand))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
